/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package examenbusiness;

import java.util.List;
import examenTO.alumnoTo;
import javax.servlet.http.HttpServletRequest;
import examenDAO.alumnoDao;

/**
 *
 * @author DANIELSITO
 */
public class alumnoBussines {
    public alumnoDao dao;
        public void insertar(HttpServletRequest r){
        alumnoTo to = new alumnoTo();
        dao = new alumnoDao();        
        to.setCodigo(r.getParameter("codigo")==null?"":r.getParameter("codigo"));
        to.setNombre(r.getParameter("nombre")==null?"":r.getParameter("nombre"));
        to.setApellpat(r.getParameter("apellpat")==null?"":r.getParameter("apellpat"));
        to.setApellmat(r.getParameter("apellmat")==null?"":r.getParameter("apellmat"));
        to.setTelefono(r.getParameter("telefono")==null?"":r.getParameter("telefono"));
        to.setDireccion(r.getParameter("direccion")==null?"":r.getParameter("direccion"));
        to.setEmail(r.getParameter("email")==null?"":r.getParameter("email"));
         to.setDni(r.getParameter("dni")==null?"":r.getParameter("dni"));
        
        dao.insertarDatosAlumno(to);        
    }
        public List reportarAlumno(){    
        dao=new alumnoDao();
        return  dao.reporteDatoAlumno();
    }
         public void eliminar(int id_alumno){
            dao=new alumnoDao();
            dao.eliminarDatosAlumno(id_alumno);
        }
         public void actualizar(HttpServletRequest r){
        alumnoTo to = new alumnoTo();
        dao = new alumnoDao();        
        to.setCodigo(r.getParameter("codigo")==null?"":r.getParameter("codigo"));
        to.setNombre(r.getParameter("nombre")==null?"":r.getParameter("nombre"));
        to.setApellmat(r.getParameter("apellpat")==null?"":r.getParameter("apellpat"));
        to.setApellmat(r.getParameter("apellmat")==null?"":r.getParameter("apellmat"));
        to.setDireccion(r.getParameter("direccion")==null?"":r.getParameter("direccion"));
        to.setTelefono(r.getParameter("telefono")==null?"":r.getParameter("telefono"));
        to.setEmail(r.getParameter("email")==null?"":r.getParameter("email"));
        to.setDni(r.getParameter("dni")==null?"":r.getParameter("dni"));
        int idAlumno=Integer.parseInt(r.getParameter("idAlumno")==null?"":r.getParameter("idAlumno"));
        dao.actualizarDatosAlumno(to,idAlumno );        
    }
}
    

